<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改成语词典')" />
    <th:block th:include="include :: select2-css" />
    <th:block th:include="include :: summernote-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-chengyu-edit" th:object="${chengyu}">
            <input name="id" th:field="*{id}" type="hidden">
            <div class="form-group">
                <label class="col-sm-3 control-label">标签：</label>
                <div class="col-sm-8">
                    <select id="tags" class="form-control select2-multiple" multiple>
                        <option th:each="tag:${tags}" th:value="${tag.name}" th:text="${tag.name}" th:selected="${tag.flag}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">拼音：</label>
                <div class="col-sm-8">
                    <input name="pinyin" th:field="*{pinyin}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">色彩：</label>
                <div class="col-sm-8">
                    <input name="secai" th:field="*{secai}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">常用程度：</label>
                <div class="col-sm-8">
                    <input name="changyong" th:field="*{changyong}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">结构：</label>
                <div class="col-sm-8">
                    <input name="jiegou" th:field="*{jiegou}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">年代：</label>
                <div class="col-sm-8">
                    <input name="niandai" th:field="*{niandai}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">同义词：</label>
                <div class="col-sm-8">
                    <textarea name="tongyici" class="form-control">[[*{tongyici}]]</textarea>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">注音：</label>
                <div class="col-sm-8">
                    <input name="zhuyin" th:field="*{zhuyin}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">反义词：</label>
                <div class="col-sm-8">
                    <textarea name="fanyici" class="form-control">[[*{fanyici}]]</textarea>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">拼音(无声调)：</label>
                <div class="col-sm-8">
                    <input name="py" th:field="*{py}" class="form-control" type="text">
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: select2-js" />
    <th:block th:include="include :: summernote-js" />
    <script src="/js/standalone.js"></script>
    <script src="/js/parser-html.js"></script>
    <script type="text/javascript">
        var prefix = ctx + "dict/chengyu";
        $("#form-chengyu-edit").validate({
            focusCleanup: true
        });


        function submitHandler() {
            if ($.validate.form()) {
                let data = $('#form-chengyu-edit').serializeArray()
                let tags = $.form.selectSelects("tags")
                data.push({"name": "tags", "value": tags});
                $.operate.save(prefix + "/edit", data);
            }
        }

        $(function() {
            $('#tags').select2({
                placeholder:"请选择标签",
                allowClear: true
            });
        })

    </script>
</body>
</html>